#ifndef WINDOWMANAGER_H
#define WINDOWMANAGER_H


#include <iostream>
#include <vector>
#include <string>
#include <boost/lexical_cast.hpp> //int --> string casting

#include "allegro.h"
#include "alleggl.h"


#include "msgManager.h"
#include "networkManager.h"
#include "xmlParser.h"

#include "windows.h"
#include "grafics.h"


using namespace std;


class networkManager;
class msgSystem;


class windowManager {

   private:


        grafics *myGrafics;


        // Pointer
        msgManager *msg;
        networkManager *net;


        int mouseX, mouseY;

        int setupFontW, setupFontH;



        // Windows
        int runningHandleNumber;

        vector<windows> Window;
        vector<int> WindowLayer;
        int WindowCNT;



        int WindowMove;
        int WindowResize;
        int WindowFocusMove;

        int WindowTempX, WindowTempY;


        void RenderWindow(int index);
        void RenderEdit(int indexID, int offsetX, int offsetY, int style);
        void RenderButton(int indexID, int offsetX, int offsetY, int style);
        void RenderText(int indexID, int offsetX, int offsetY, int style);
        void RenderImage(int indexID, int offsetX, int offsetY, int style);


        // Functions
        void loadXML(void);
        bool isPlainChar(int pAsciiCode);
        string breakLines(string pText, int w);
        int windowGetIndexByHandle(int pHandle);
        int windowGetIndexById(int pId);
        int windowGetLayerPosition(int pHandle);


	public:

		windowManager();
		~windowManager();


        // Functions
        void Init(void);
        void IntroduceMessage(msgManager *pMsg);
        void IntroduceNetwork(networkManager *pNet);
        void Draw(void);
        void Calculate(void);
        void Render(bool pInit);
        void InjectMouse(int pMausX, int pMausY);
        void InjectKeys(int pKey);

      string windowGetEdit(int pWindowID, int pButtonID);

         int windowGetNumber(void);
         int windowGetFocused(void);
         int windowSetFocus(int pHandle);
         int windowAdd(windows pWindow);
        bool windowClick(int pClickX, int pClickY);
        bool windowClickContent(int pClickX, int pClickY, int indexID);
        void windowClickHandler(int indexID, int objectID, int type);
        void windowMove(int pDiffX, int pDiffY, int pMausX, int pMausY);
        void windowClickRelease();
        void windowOpen(int pHandle);
        void windowClose(int pHandle);


        int debug;

};



#endif // SRWINDOWMANAGER_H
